<!--  -->
<template>
  <div class="editable-cell" :class="required ? 'requiredFormItem' : ''">
    <a-month-picker v-if="type=='month'" @change="handleChange" :value="text" format="YYYY-MM" placeholder="请选择" :disabled="disabled" :disabled-date="disabledDate" />
    <a-date-picker v-else @change="handleChange" :value="text" format="YYYY-MM-DD" placeholder="请选择" :disabled="disabled" :disabled-date="formatDisabledDate" />
  </div>
</template>

<script>
export default {
  name: 'EditableDate',
  props: {
    type: String,
    text: [String, Number],
    disabled: {
      type: Boolean,
      defalut: false
    },
    required: {
      type: Boolean,
      defalut: false
    },
    disabledDate: {
      type: [String, Date],
      defalut: ''
    }
  },
  data() {
    return {}
  },

  components: {},

  computed: {},

  created() {},

  mounted() {},

  methods: {
    handleChange(val) {
      let keys = { 'month':'YYYY-MM',}
      this.$emit('change', this.moment(val).format(keys[this.type]?keys[this.type]:'YYYY-MM-DD'))
    },
    formatDisabledDate(current) {
      if (this.disabledDate) {
        return current && current < this.moment(this.disabledDate).startOf('day');
      } else {
        return false
      }
    }
  }
}
</script>
<style lang='less' scoped>
// /deep/.ant-calendar-picker-input {
//   border: none;
// }
</style>